//
//  RootTabBarController.m
//  project
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "RootTabBarController.h"
#import "UserViewController.h"
#import "CatogryViewController.h"
#import "HotViewController.h"
#import "MainViewController.h"

@interface RootTabBarController ()

-(void)p_setupControllers;

@end

@implementation RootTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 添加视图控制器
    [self p_setupControllers];
}


// 添加controller
-(void)p_setupControllers
{
    // 主页
    MainViewController *mainVC = [[MainViewController alloc]init];
    UINavigationController *mainNC = [[UINavigationController alloc]initWithRootViewController:mainVC];
    
    mainNC.navigationBar.backgroundColor = [UIColor magentaColor];
    mainNC.tabBarItem.title = @"首页";
    mainNC.tabBarItem.image = [UIImage imageNamed:@"main"];
    mainNC.tabBarItem.selectedImage = [[UIImage imageNamed:@"main_isselect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [mainNC.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor purpleColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];
    

    
    
    // 热门
    HotViewController *hotVC = [[HotViewController alloc]init];
    UINavigationController *hotNC = [[UINavigationController alloc]initWithRootViewController:hotVC];
    
    hotNC.navigationBar.backgroundColor = [UIColor magentaColor];
    hotNC.tabBarItem.title = @"热门";
    hotNC.tabBarItem.image = [UIImage imageNamed:@"hot"];
    hotNC.tabBarItem.selectedImage = [[UIImage imageNamed:@"hot_isselect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [hotNC.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor purpleColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];
    
    
    //分类
    CatogryViewController *catogryVC = [[CatogryViewController alloc]init];
    UINavigationController *catogryNC = [[UINavigationController alloc]initWithRootViewController:catogryVC];
    
    catogryNC.navigationBar.backgroundColor = [UIColor magentaColor];
    catogryNC.tabBarItem.title = @"分类";
    catogryNC.tabBarItem.image = [UIImage imageNamed:@"catogry"];
    catogryNC.tabBarItem.selectedImage = [[UIImage imageNamed:@"catogry_isselect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [catogryNC.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor purpleColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];
    
    // 我的
    UserViewController *userVC = [[UserViewController alloc]init];
    UINavigationController *userNC = [[UINavigationController alloc]initWithRootViewController:userVC];
    
    userNC.navigationBar.backgroundColor = [UIColor magentaColor];
    userNC.tabBarItem.title = @"我的";
    userNC.tabBarItem.image = [UIImage imageNamed:@"user"];
    userNC.tabBarItem.selectedImage = [[UIImage imageNamed:@"user_isselect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [userNC.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor purpleColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];
    
    
    self.viewControllers = @[mainNC, hotNC, catogryNC, userNC];
    
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
